import urllib.request
import urllib.parse

url = 'https://fanyi.baidu.com/v2transapi?from=zh&to=en'
user = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36'

data={}
data['from']= 'zh'
data['to']= 'en'
data['query']= '我爱你'
data['transtype']= 'translang'
data['simple_means_flag']= '3'
data['token']= 'af7d70353e02d49997285f0cbf3241d8'

data=urllib.parse.urlencode(data).encode('utf-8')

req=urllib.request.Request(url,data)
req.add_header('user-agent',user)

response = urllib.request.urlopen(url)
html = response.read().decode('utf-8')

print(html)
